import java.util.HashMap;
import java.util.Map;

public class TestMain {
    public static void main(String[] args) {
        int[] array = {1,2,2,5,5,6,8,2};
        Map<Integer,Integer> map = new HashMap<>();
        for (int x : array) {
            if(map.get(x) == null) {
                map.put(x,1);
            } else {
                int val = map.get(x);
                map.put(x,val+1);
            }
        }
        for(Map.Entry<Integer,Integer> set: map.entrySet()) {
            if(set.getValue() >= 2) {
                System.out.println("key:"+set.getKey()+" val:" + set.getValue());
            }
        }
    }
}
